<?php 
	$f = fopen("http://www.sina.com", 'r');
	$buffer="";
	while (!feof($f)) {
		$buffer .= fgets($f,4096);
	}

	$buffer=preparePage($buffer);
  echo $buffer;

  function preparePage($content) {
    $attrs=array("id","class","style","type","value","onclick","alt","onblur","align"
      ,"onfocus","autocomplete","onsubmit","name","target","method","onmouseover","title","action","rel","src");
    $tags =array("script","style","link","iframe");

    $content=rmTags($content,$tags);
    $content=rmCom($content);
    $content=rmAttrs($content,$attrs);
  	
    return $content;
  }

  function rmAttrs($content,$attrs){
    if(!empty($attrs)){
      //echo "noempty";
      foreach ($attrs as $attr) {
        $content = preg_replace("%".$attr."[\s]*=[\s]*['\"][\s\S]*['\"]"."%imsU", "", $content);
      }
    }  

    return $content;    
  }


  function rmTags($content,$tags){
    foreach ($tags as $tag) {
      $content=preg_replace("%<".$tag."[\s\S]*</".$tag.">%imsU", "", $content);
    }
    return $content;
  }

  function rmCom($content){
    $tmp="";
    //remove conditional comment support in ie
    $tmp = preg_replace("%<!--[if[\s\S]*endif]-->%imsU","",$content);

    //remove normal comments
    $tmp = preg_replace("/<!--.*>/imsU", "", $tmp);

    return $tmp;
  }
 ?>